<p class="setting-one">
	<span>院系代码：<input type="text" name="code" value="<{$academy.code}>"/></span>
	<span>院系名称：<input type="text" name="name" value="<{$academy.name}>"/></span>
    <button style="margin-top:-10px;" class="btn btn-primary" name="modify">修改</button>
</p>
<hr>
<div class="setting-two">
	<select name="major">
	<option>-----请选择-----</option>
	</select>
    <span>专业代码:</span><input type="text" name="majorcode" value="" disabled/>
    <span>专业名称:</span><input type="text" name="majorname" value=""/><br/><br/>
	<p>
        <button style="margin-top:-10px;margin-left: 70px;" class="btn btn-primary" name="new">新建一个专业</button>
        <button style="margin-top:-10px;margin-left:50px;" class="btn btn-primary" name="submit">提交修改</button><button style="margin-top:-10px;margin-left:50px;" class="btn btn-primary" name="delete">删除该专业</button>
	</p>
</div>
<hr>
<div class="setting-three">
	<select name="class">
	<option>-----请选择-----</option>
	</select>
    <span>班级代码:</span><input type="text" name="classcode" value="" disabled/>
    <span>班级名称:</span><input type="text" name="classname" value=""/><br/><br/>
	<p>
		<input type="hidden" name="premajor" value=""/>

        <button style="margin-top:-10px;margin-left:70px;" class="btn btn-primary" name="new">新建一个班级</button>
        <button style="margin-top:-10px;margin-left:50px;" class="btn btn-primary" name="submit">提交修改</button>
        <button style="margin-top:-10px;margin-left:50px;" class="btn btn-primary" name="delete">删除该班级</button>
	</p>
</div>
<script>
	var setting=new PureAjax();
	var icode=document.getElementsByName("code")[0];
	var iname=document.getElementsByName("name")[0];
	var major=document.getElementsByName("major")[0];
	var iclass=document.getElementsByName("class")[0];
	var majorcode=document.getElementsByName("majorcode")[0];
	var majorname=document.getElementsByName("majorname")[0];
	var classcode=document.getElementsByName("classcode")[0];
	var classname=document.getElementsByName("classname")[0];
	var submits=document.getElementsByName("submit");
	var news=document.getElementsByName("new");
	var modify=document.getElementsByName("modify")[0];
	var premajor=document.getElementsByName("premajor")[0];
	var deletes=document.getElementsByName("delete");
	setting.post({
		dataType:"json",
		data:{},
		async:true,
		url:URL+"Request/getMajorList",
		success:function(data){
			var length=data.length;
			for(j=0;j<length;j++){
				opt=document.createElement("option");
				opt.value=data[j].code;
				opt.innerHTML=data[j].name;
				major.appendChild(opt);
			}
			premajor.value=major.options[1].value;
		}
	});
	major.onchange=function(){
		majorcode.value=this.value;
		premajor.value=this.value;
		majorname.value=this.options[this.selectedIndex].text;
		setting.post({
			dataType:"json",
			data:{getmajor:major.value},
			async:true,
			url:URL+"Request/getClassList",
			success:function(data){
				var length=data.length;
				iclass.innerHTML="";
				for(j=0;j<length;j++){
					opt=document.createElement("option");
					opt.value=data[j].code;
					opt.innerHTML=data[j].name;
					iclass.appendChild(opt);
				}
				classcode.value=iclass.options[0].value;
				classname.value=iclass.options[0].text;

			}
		});
		
	}
	iclass.onchange=function(){
		classcode.value=this.value;
		classname.value=this.options[this.selectedIndex].text;
	}
	news[0].onclick=function(){
		majorname.value="";
		majorcode.value="";
		majorcode.disabled=false;
		majorcode.focus();
	}
	news[1].onclick=function(){
		classname.value="";
		classcode.value="";
		classcode.disabled=false;
		classcode.focus();
	}
	modify.onclick=function(){
		setting.post({
			dataType:"text",
			data:{code:icode.value,name:iname.value},
			async:true,
			url:URL+"System/changeSetting/type/academy",
			success:function(data){
				alert(data);
			}
		});
	}
	submits[0].onclick=function(){
		setting.post({
			dataType:"text",
			data:{code:majorcode.value,name:majorname.value},
			async:true,
			url:URL+"System/changeSetting/type/major",
			success:function(data){
				alert(data);
			}
		});
	}
	submits[1].onclick=function(){
		setting.post({
			dataType:"text",
			data:{code:classcode.value,name:classname.value,itype:premajor.value},
			async:true,
			url:URL+"System/changeSetting/type/class",
			success:function(data){
				alert(data);
			}
		});
	}
	deletes[0].onclick=function(){
		setting.post({
			dataType:"text",
			data:{code:majorcode.value,itype:"major"},
			async:true,
			url:URL+"System/changeSetting/type/delete",
			success:function(data){
				alert(data);
			}
		});
	}
	deletes[1].onclick=function(){
		setting.post({
			dataType:"text",
			data:{code:classcode.value,itype:premajor.value},
			async:true,
			url:URL+"System/changeSetting/type/delete",
			success:function(data){
				alert(data);
			}
		});
	}
</script>